package lambdasinaction.chap10.ex;

import lambdasinaction.chap10.*;

import java.util.Optional;

/**
 * Created by gx on 2017/4/24.
 */
public class MyTest {

    public String getCarInsuranceName(Optional<Person> person){
        return person.flatMap(Person::getCar)
                .flatMap(Car::getInsurance)
                .map(Insurance::getName)
                .orElse("unKnown");
    }
}



